package com.yangwp.jie.service.impl;

import com.google.common.collect.Maps;
import com.yangwp.jie.dao.JieUserDao;
import com.yangwp.jie.model.JieUser;
import com.yangwp.jie.service.JieUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class JieUserServiceImpl implements JieUserService {

    @Autowired
    private JieUserDao jieUserDao;

    @Override
    public Boolean add(JieUser jieUser){
        if(jieUser != null){
            try {
                return jieUserDao.insert(jieUser) > 0;
            }catch (Exception e){
                System.out.println(e);
            }
        }
        return Boolean.FALSE;
    }

    @Override
    public Boolean loginCheck(String nickName, String password){
        try {
            Map<String, Object> params = Maps.newHashMap();
            params.put("nickName", nickName);
            params.put("password", password);
            return jieUserDao.countUser(params) == 1;
        }catch (Exception e){
        }
        return Boolean.FALSE;
    }

}
